package com.moyq5.mvc.framework.jackson;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module.Feature;

public class HibernateObjectMapper extends ObjectMapper {
	
	private static final long serialVersionUID = 1L;
	
	public HibernateObjectMapper() {
		Hibernate5Module hibernate5Module= new Hibernate5Module();
		hibernate5Module.configure(Feature.FORCE_LAZY_LOADING, true);
		registerModule(hibernate5Module);

		
		//setSerializationInclusion(Include.NON_EMPTY);
		
		disable(SerializationFeature.WRITE_NULL_MAP_VALUES);
		disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
		enable(SerializationFeature.WRITE_ENUMS_USING_INDEX);
		
		disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
		disable(DeserializationFeature.FAIL_ON_NUMBERS_FOR_ENUMS);
		enable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL);
		
		//disable(MapperFeature.AUTO_DETECT_CREATORS);
		//disable(MapperFeature.AUTO_DETECT_FIELDS);
		//disable(MapperFeature.AUTO_DETECT_GETTERS);
		//disable(MapperFeature.AUTO_DETECT_IS_GETTERS);
		//disable(MapperFeature.AUTO_DETECT_SETTERS);
		
		//configure(JsonGenerator.Feature.ESCAPE_NON_ASCII,true);
	}
	
}
